package sy.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import sy.model.Taccount;
import sy.pageModel.Json;
import sy.pageModel.PageAccount;
import sy.service.TaccountServiceI;

/**
 * 
 * @author ray 
 * 科目controller
 */
@Controller
@RequestMapping("/taccountController")
public class TaccountController {

	private TaccountServiceI taccountService;

	public TaccountServiceI getTaccountService() {
		return taccountService;
	}

	@Autowired
	public void setTaccountService(TaccountServiceI taccountService) {
		this.taccountService = taccountService;
	}

	@RequestMapping("/datagrid")
	@ResponseBody
	public List<PageAccount> datagrid() {
		return taccountService.treegrid();
	}

	@RequestMapping(value = "/add", method = RequestMethod.POST)
	@ResponseBody
	public Json add(Taccount taccount) {
		Json j = new Json();
		j.setSuccess(true);
		j.setObj(taccountService.add(taccount));
		j.setMsg("添加成功!");
		return j;
	}

	@RequestMapping(value = "/edit")
	@ResponseBody
	public Json edit(Taccount taccount) {
		Json json = new Json();
		json.setSuccess(true);
		json.setObj(taccountService.edit(taccount));
		json.setMsg("编辑成功");
		return json;
	}
	@RequestMapping(value = "/remove")
	@ResponseBody
	public Json remove(String ids) {
		Json json = new Json();
		taccountService.remove(ids);
		json.setSuccess(true);
		json.setObj(ids);
		json.setMsg("删除成功");
		return json;
	}

}
